var fs = require('fs');
var express = require('express');
var app = express();
var portada = fs.readFileSync('indexC10.html','utf8');


app.get('/', function (req, res) {   
	res.send(portada);
});
app.get('/js/:page', function (req, res) { 
    var js = fs.readFileSync(req.params.page);
    res.contentType('text/javascript');
    res.send(js);
});
app.post('/creardoc/:nombre/:edad/:domicilio',function(req,res){
var nano = require('nano')('http://pilaram.iriscouch.com/');
var db_name = "bloquec10";
var db = nano.use(db_name);
//Hacemos la solicitud a la base de datos:
db.insert( {'nombre':req.params.nombre,
		'edad':req.params.edad,
		'domicilio':req.params.domicilio},
           function (error,http_body,http_headers) {
               console.log(http_body);
           }
           );
});


app.listen(8080);
console.log('Server running at http://127.0.0.1:8080/');
